"use strict";

/**
 * @returns {{ a: number; b: () => void; c: () => number; d: () => void; }}
 */
const a = () => {
  let a = 1;
  const fr = new FinalizationRegistry(() => console.log("finalize"));
  return {
    a,
    b() {
      // never bind this
      this.a += 1;
    },
    c: () => a,
    d() {
      // closure bind 'a' in function a
      a += 1;
    },
  };
};

const c = a();
// console.log(c.a);
// console.log(c.b());
// console.log(c.a);

console.log(c.c());
console.log(c.d());
console.log(c.c());
